Imports WindowsLive.Writer.Api
Imports System.Windows.Forms
Imports System.IO

<System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1705:LongAcronymsShouldBePascalCased")> _
<WriterPluginAttribute("8FEFDED4-5D79-4925-85DE-65181856BE36", _
    "Picture Post", _
    ImagePath:="picture.png", HasEditableOptions:=False, _
    PublisherUrl:="http://coolthingoftheday.blogspot.com/", _
    Description:="Upload and post pictures")> _
<InsertableContentSourceAttribute("Picture Post")> _
Public Class WLWPlugin
  Inherits ContentSource

  Private _Settings As Settings

  Public Sub New()

  End Sub

  Public Overrides Sub Initialize(ByVal pluginOptions As WindowsLive.Writer.Api.IProperties)
    MyBase.Initialize(pluginOptions)
    _Settings = New Settings(pluginOptions)
  End Sub

  Public Overrides Function CreateContent(ByVal dialogOwner As IWin32Window, ByRef newContent As String) As DialogResult
    Dim RelatedPostForm As PicturePost
    Dim result As DialogResult

    RelatedPostForm = New PicturePost
    result = RelatedPostForm.ShowDialog(dialogOwner, _Settings)

    If result = DialogResult.OK Then

      If RelatedPostForm.HTMLResult.Length > 0 Then
        newContent = RelatedPostForm.HTMLResult
        RelatedPostForm.Dispose()
        Return result

      Else
        RelatedPostForm.Dispose()
        Return DialogResult.Cancel
      End If

    Else
      RelatedPostForm.Dispose()
      Return result

    End If

  End Function

  Public Overrides Sub EditOptions(ByVal dialogOwner As System.Windows.Forms.IWin32Window)
    'Dim EditOptions As Options
    'Dim NewTemplatePath As String = ""

    'EditOptions = New Options

    'EditOptions.ShowDialog(dialogOwner, _Settings)

    'EditOptions.Dispose()

  End Sub

End Class
